﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Uniforax.Core.Armors;
using Uniforax.Core.Common;
using Uniforax.Core.GameObjects;

namespace Uniforax.Camp.TestData.Common
{
    public enum TestDataArmorEnum
    {
        None, Armor2,
    }

    public class TestDataArmorManager : BaseArmorManager
    {
        private TestDataArmor _testDataArmor;
        private TestDataArmor2 _testDataArmor2;

        public TestDataArmorEnum ArmorType { get; set; } = TestDataArmorEnum.None;


        public TestDataArmorManager()
        {
            _testDataArmor = new TestDataArmor();
            _testDataArmor2 = new TestDataArmor2();
        }

        public override BaseArmor GetPrimaryArmor()
        {
            if (ArmorType == TestDataArmorEnum.None) return _testDataArmor;
            else if (ArmorType == TestDataArmorEnum.Armor2) return _testDataArmor2;
            return null;
        }

        public static void HandleOnPlaceUnlockUpgradeArmorAuto(ActionContext context, BaseGameObject gameObject)
        {
            if (gameObject.CreateStatus == CreateStatus.Completed) return;
            if (gameObject.ArmorManager is not TestDataArmorManager) return;
            var world = context.GameWorld;
            var playerData = world.GetPlayerData(context.PlayerId);

            var unlockUngradeArmor = playerData.GetField(Shared.UnlockUpgradeArmorSkillId);

            if (unlockUngradeArmor)
            {
                var upgradeArmorAction = new UpgradeTestDataArmorAction(gameObject);
                context.History.Add(upgradeArmorAction);
                upgradeArmorAction.Execute(context);
            }
        }

    }
}
